﻿using SqlSugar;
using System.Threading.Tasks;

namespace AlipayPay.Infrastructure.EntitiyExtensions
{
    /// <summary>
    /// 单元模式
    /// </summary>
    public interface IUnitOfWork
    {
        // 创建 sqlsugar client 实例
        ISqlSugarClient GetDbClient();

        /// <summary>
        /// 开始事务
        /// </summary>
        /// <returns></returns>
        Task BeginTran();

        /// <summary>
        /// 提交事务保存至数据库
        /// </summary>
        /// <returns></returns>
        Task<bool> CommitTran();

        /// <summary>
        /// 回滚
        /// </summary>
        /// <returns></returns>
        Task RollBack();

        /// <summary>
        /// 提交
        /// </summary>
        /// <returns></returns>
        Task<bool> CommitAsync();
    }
}
